<?php 
	$relacionadas = $this->request->data['propRelacionada'];	
?>
<html>
	<body>
		<h3>Propiedades relacionadas de "<?php echo $this->request->data['Propiedade']['direccion'] ?>"</h3>
		<?php 
		echo $this->Html->link('Agregar Relación', array('controller' => 'Relacionadas', 'action' => 'add',$this->request->data['Propiedade']['id']));
		?>
		<?php echo $this->Form->create('Relacion') ?>
		<table>
			<thead class="listHeader">
				<tr>
					<td></td>
					<td>ID</td>
					<td>Dirección</td>										
					<td>Descripción</td>
					<td>Destacada</td>
					<td>Acciones</td>							
				</tr>
			</thead>
			<tbody>				
				<?php foreach($Propiedades as $props):
					$esRel = false;
					foreach($relacionadas as $rel){
						$esRel = $esRel || $rel['id'] === $props['Propiedade']['id']; 
					}
				?>					
					<tr>
						<td>
							<?php
								
								echo $this->Form->checkbox('seleccionadas.',array(
									'value' => $props['Propiedade']['id'],
									'checked' => $esRel,
									'hiddenField'=>false		
								));
							?>
						</td>
						<td><?php echo $props['Propiedade']['id'] ?></td>
						<td><?php echo $props['Propiedade']['direccion'] ?></td>
						<td><?php echo $props['Propiedade']['descripcion'] ?></td>
						<td><?php echo $props['Propiedade']['Destacada'] ?></td>						
						
					</tr>
				<?php
					endforeach;								
				?>
			</tbody>
		</table>
		<?php echo $this->Form->end('Guardar Cambios'); ?>
	</body>
</html>